import java.util.Arrays;

public class Test {

    public static void main1(String[] args) {
        String s = "aaabbbcccaaabbbccc";
        System.out.println(s.charAt(3));
        System.out.println(s.indexOf('c'));
        System.out.println(s.indexOf('c', 10));
        System.out.println(s.indexOf("bbb"));
        System.out.println(s.indexOf("bbb", 10));
        System.out.println(s.lastIndexOf('c'));
        System.out.println(s.lastIndexOf('c', 10));
        System.out.println(s.lastIndexOf("bbb"));
        System.out.println(s.lastIndexOf("bbb",10));
        System.out.println(s.indexOf("b"));
    }

    public static void main11(String[] args) {
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        String s4 = String.valueOf(new Student("zhangsan", 32));
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);

        int data1 = Integer.parseInt("123");
        double data2 = Double.parseDouble("12.34");
        System.out.println(data1);
        System.out.println(data2);
    }

    public static void main111(String[] args) {

        String s1 = "hello";
        String s2 = "HELLO";
        System.out.println(s1.toUpperCase() + " " + s1);
        System.out.println(s2.toLowerCase() + " " + s2);
        String s3 = s1.toUpperCase();
        String s4 = s1.toLowerCase();
        System.out.println(s3 == s1);
        System.out.println(s4 == s1);
    }

    public static void main2(String[] args) {

        String s = "hello";
        char ch1 = s.charAt(3);
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.println(ch[i]);
        }
        String s1 = Arrays.toString(ch);
        System.out.println(s1);
    }

    public static void main22(String[] args) {

        String s = "hello";
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.println(ch[i]);
        }

        String s1 = new String(ch);
        System.out.println(s1);
    }

    public static void main222(String[] args) {

        String s = String.format("%d-%d-%d", 2019, 9, 14);
        System.out.println(s);
    }

    public static void main2222(String[] args) {

        String s = String.format("%d %d %d", 2019, 9, 14);
        System.out.println(s);
    }

    public static void main22222(String[] args) {

        String s = "helloworld";
        System.out.println(s.replaceAll("|", "_"));
        System.out.println(s.replace("|", "_"));
        System.out.println(s.replaceFirst("|", "_"));
    }

    public static void main3(String[] args) {

        String s = "helloworld";
        System.out.println(s.replaceAll("|", "a"));
        System.out.println(s.replaceFirst("|", "w"));
        System.out.println(s.replace("o", "_"));
    }

    public static void main33(String[] args) {

        String s = "hello world hello bit";
        String[] rs = s.split(" ");
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }
    }

    public static void main333(String[] args) {

        String s = "hello world hello bit";
        String[] rs = s.split(" ");
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }

        System.out.println("--------------");
        String[] p = s.split("o");
        for (int i = 0; i < p.length; i++) {
            System.out.println(p[i]);
        }
    }

    public static void main5(String[] args) {
        String str = "hello world hello bit";
        String[] rs = str.split(" ", 2);
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }
    }

    public static void main12(String[] args) {

        String s = "hello world hello bit";
        String[] rs = s.split(" ", 3);
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }
    }

    public static void main32(String[] args) {

        String s = "192.168.1.1";
        String[] rs = s.split("\\.");
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }
    }

    public static void main123(String[] args) {

        String s = "192.168.1.1";
        String[] rs = s.split("\\.");
        for (int i = 0; i < rs.length; i++) {
            System.out.println(rs[i]);
        }
        String s1 = "192\\168\\1\\1";
        String[] p = s1.split("\\\\");
        for (int i = 0; i < p.length; i++) {
            System.out.println(p[i]);
        }

        String s2 = "name=zhangsan&age=18$32";
        String[] p1 = s2.split("=|&|\\$");
        for (int i = 0; i < p1.length; i++) {
            System.out.println(p1[i]);
        }
    }

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        String s = "";
        for (int i = 0; i < 10000; i++) {
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for (int i = 0; i < 10000; i++) {
            sbf.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder("");
        for (int i = 0; i < 10000; i++) {
            sbd.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);
    }
}

class Student{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
